#!/bin/bash
# Copyright (c) 2024 maminjie <canpool@163.com>
# SPDX-License-Identifier: MulanPSL-2.0

#
# Dependencies:
#   ola (https://gitee.com/icanpool/shcanpool/tree/master/projects/ola)
#

failed_file=$1

if [[ $# -lt 1 || ! -f "$failed_file" ]]; then
    echo "usage: bash $0 failed_file"
    exit 0
fi

while read i; do
    spec_file=$(ola c gec_get_trees src-openeuler $i master | grep -E "\.spec$" | sed 's/.spec//g' | head -1)
    if [ -z "$spec_file" ]; then
        echo "$i,null"
    else
        echo "$i,$spec_file"
    fi
done < $failed_file
